// 开始的值 = （当前页码-1）* 每页数量
// start = (obj.pno - 1) * obj.count
// size = parseInt(obj.count)
// query("select * from xz_user limit ?,?",[start,size])

const express = require("express")
const {page} = require('../mysql.js')

const pagesRouter = express.Router()
pagesRouter.post("/pages",(req,res)=>{
    console.log(req.body);
    let sql = "select * from comput limit ?,?"
    let start = (req.body.pno-1) * req.body.count
    let size = parseInt(req.body.count)
    page(sql,start,size).then(result=>{
        res.send({
            code:200,
            message:'查询成功！',
            data:result
        })
    }).catch(err=>{
        console.log(err);
        res.send({
            code:201,
            message:'查询失败！'
        })
    })
})

module.exports = {pagesRouter}